1. Field of the Invention
Embodiments of this invention relate to multithreaded computing systems. More particularly, an embodiment of the present invention relates to lock acquisition hierarchy violation detection in multithreaded programs.
2. Description of Related Art
In a multithreaded program, different threads can handle different tasks and proceed in parallel to improve speed and efficiency. These different threads can share resources and some resources are shared only in a manner that is mutually exclusive. The mutually exclusive resources may include, but are not limited to, synchronization objects such as critical sections, mutex locks, and writer locks.
When different threads in a multithreaded program acquire multiple sets of mutually exclusive resources while holding some other mutually exclusive resources, a consistent order of resource acquisitions has to be followed by each of such threads to acquire the resources. The consistent order is referred to as a lock acquisition hierarchy. The term “lock” may be used synonymously and interchangeably with the term “resource” throughout this disclosure. Failing to adhere to a consistent resource acquisition order is regarded as a lock acquisition hierarchy violation. Lock acquisition hierarchy violations can potentially cause various problems, such as program deadlocks. Lock acquisition hierarchy violations are often regarded as program errors.